﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using App_Code.Clases;
using Image = System.Drawing.Image;
using System.Drawing;
using SubSonic.Repository;

public partial class Mantenimiento_RetornarImagen : System.Web.UI.Page
{
    SimpleRepository repository= new SimpleRepository("Electro",SimpleRepositoryOptions.None);
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["Id"] == null) return;
        var producto = repository.Single<Producto>(int.Parse(Request.QueryString["Id"]));
        var image = producto.Imagen;

        if (image != null)
        {
            Response.ContentType = "image/jpeg";
            using (var ms = new MemoryStream(image))
            {
                using (var jpg = (Bitmap)Image.FromStream(ms))
                {
                    jpg.Save(Response.OutputStream, ImageFormat.Jpeg);
                }
            }
        }
        return;

    }
}
